<!-- Loads initialization file with a couple of variables -->

<%@ include file="../../inc/init.jsp" %>

<html>
	<head>
		<title>
			Graduate Admission System | University of California - San Diego | 
			Address Page
		</title>
		<link type="text/css" rel="stylesheet" href="<%= BASE %>css/main.css">
		<link type="text/css" rel="stylesheet" href="<%= BASE %>css/expand.css">
	</head>
	<body>
	<div class="header-top"></div>
		<div class="header">
			<a href="<%= BASE %>index.jsp"><img src="<%= BASE %>img/logo.png"></a>
		</div>
		<div class="content">
		<div class="message"></div>
		<%
			try {
		
			/**** Get applicant object ****/
		
			Applicant a = (Applicant)session.getAttribute("applicant");
			
			/**** Get parameters via URL from previous page and store to applicant object ****/
			
			a.setCountryOfResidence(request.getParameter("countryOfResidence"));
			a.setCountryOfResidenceId(Integer.parseInt(request.getParameter("id")));
			
			/** Store applicant object to session object **/
			
			session.setAttribute("applicant", a);
	
		%>	
		<h2>Previous Data:</h2>
		
		<ol class="tree">
			<li><label for="general">General Information</label><input type="checkbox" id="general" />
				<ol> 
					<li>
						<table>
							<tr><td>First Name:</td><td><%= a.getFirstName() %></td></tr>
							<tr><td>Middle Initial:</td><td><%= a.getMiddleInitial() %></td></tr>
							<tr><td>Last Name:</td><td><%= a.getName() %></td></tr>
							<tr><td>Country of Citizenship:</td><td><%= a.getCountryOfCitizenship() %></td></tr>
							<tr><td>Country of Residence:</td><td><%= a.getCountryOfResidence() %></td></tr>
						</table>
					</li>
				</ol>
			</li>
		</ol>
		<hr>
		<br>
			
			Please type in the information needed regarding the place you live.
			
			<br><br>
				
			<form method="GET" action="residency.jsp">
				<table>
				<tr><td>Street:</td><td><input name="street" size="30"></td></tr>
				<tr><td>City:</td><td><input name="city" size="30"></td></tr>
				<%
					/**** Decide whether country of residence is the US or not to determine
						  whether the field 'state' or 'country phone code' is displayed ****/
					
					if(a.getCountryOfResidence().equals("United States"))
					{
						out.print("<tr><td>State:</td><td><input name=\"state\" size=\"30\"></td></tr>");
					}
					else
					{
						out.print("<tr><td>Country Phone Code:</td><td><input name=\"countryPhoneCode\" maxlength=\"5\" size=\"4\"></td></tr>");
					}
				%>
				<tr><td>ZIP/Postal Code:</td><td><input name="zip" maxlength="5" size="4"></td></tr>
				<tr><td>Area Code:</td><td><input name="areaCode" maxlength="4" size="4"></td></tr>
				<tr><td>Number:</td><td><input name="number" size="10"></td></tr>
				<tr><td colspan="2"><input type="submit" value="Submit"></td></tr>
				</table>
			</form>
			<%
				}
				catch(Exception e)
				{
					response.sendRedirect(BASE + "error.jsp");
				}
			%>
		</div>
	</body>
</html>